import { createRouter, createWebHashHistory } from 'vue-router'
import layout from '@/layout'
const publicRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index')
  },
  {
    path: '/',
    component: () => import('@/layout/index')
  }
]

const privateRoutes = [
  {
    path: '/user',
    component: layout,
    redirect: '/user/manage',
    meta: {
      title: '用户管理',
      icon: 'personnel'
    },
    children: [
      {
        path: '/user/manage',
        component: () => import('@/views/user-manage/index'),
        meta: {
          title: '用户列表',
          icon: 'personnel-manage'
        }
      }, {
        path: '/user/info/:id',
        name: 'userInfo',
        component: () =>
          import('@/views/user-info/index'),
        props: true,
        meta: {
          title: '用户信息'
        }
      }, {
        path: '/user/import',
        name: 'import',
        component: () =>
          import('@/views/import/index'),
        meta: {
          title: 'excel导入'
        }
      },
      {
        path: '/user/userAdd',
        name: 'userAdd',
        component: () =>
          import('@/views/user-manage/userEdit'),
        meta: {
          title: '新增用户'
        }
      },
      {
        path: '/user/userEdit',
        name: 'import',
        component: () =>
          import('@/views/user-manage/userEdit'),
        meta: {
          title: '编辑用户'
        }
      }]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: [...publicRoutes, ...privateRoutes]
})

export default router
